// ==UserScript==
// @name         有道翻译关闭广告
// @namespace    http://tampermonkey.net/
// @version      2024-04-14
// @description  try to take over the world!
// @author       You
// @match        https://fanyi.youdao.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youdao.com
// @grant        none
// 建议翻译网址   https://fanyi.youdao.com/#/TextTranslate
// ==/UserScript==

(function () {
    'use strict';

    // let div = document.createElement('div');
    // div.style.position = 'fixed';
    // div.style.top = '0';
    // div.style.left = '0';
    // div.style.width = '10%';
    // div.style.height = '10%';
    // div.style.backgroundColor = 'rgba(0,0,0,0.5)';
    // div.style.border='1px solid #fff';
    // document.getElementsByTagName('body')[0].appendChild(div);

    let class_name = [
        'header-outer-container',   // 顶部登录栏
        'tab-header',   // 顶部选项
        'dict-website-footer footer-default',   // 底部栏
        'sidebar-container',    // 侧边栏
        'document-upload-entrance-container drag-area',// 输入拖动框
        'guide-content',    // 指引
        'sourceAction',     // 翻译后输入框内提示
        'targetAction',     // 翻译后输出框内提示
        'box_ch',   // 翻译后的下方提示
        'top-banner-outer-container',   // 顶部广告
    ];

    // 循环判断存在并进行选择性隐藏
    let count = 0;
    let t = setInterval(() => {
        for (let i = 0; i < class_name.length; i++) {
            if (document.getElementsByClassName(class_name[i])[0]) {
                document.getElementsByClassName(class_name[i])[0].style.display = 'none'
                count++;
            }
        }
        if (count >= class_name.length) {
            console.log('wmyqq-所有广告元素已隐藏');
            clearInterval(t);
        }
    }, 500);

    let t2 = setInterval(() => {
        if (document.getElementsByClassName('web-frame-content-scroll-container index-bg')[0]) {
            document.getElementsByClassName('web-frame-content-scroll-container index-bg')[0].style.backgroundImage = 'url()'
            // document.getElementsByClassName('web-frame-content-scroll-container index-bg')[0].style.backgroundColor = 'black';
            clearInterval(t2);
        }
    }, 500); // 10秒后清除定时器
})();


